<?php

/**
 * @file
 * Test suite for dbEvent module.
 * 
 * Copyright 2011 by UNHM CIS605 project Donate team.
 * This program is part of BBBS and YWCA Donation management system.
 * Donate is free software. It comes with absolutely no warranty.
 * You can redistribute it and/or modify it under the terms of the GNU
 * General Public License as published by the Free Software Foundation
 * (see <http://www.gnu.org/licenses/ for more information).
 * 
 * @version March 7, 2011
 * @author Laura Cassella
 */
/**
 * Include the php file that is being tested.
 */
include_once(dirname(_FILE_) . '/../database/dbEvent.php');
/**
 * Test characteristics of Event table.
 */
class testdbEvent extends UnitTestCase {

    function testdbEventModule() {
        // Add an event.
        $m = new Event("4", "5", "2011-2-26", "66 Second Ave.", "New York", "NY", "04106-2255");
        $this->assertTrue(addEvent($m));

        //get an event.
        $i = get_eventID('4');
        $this->assertTrue($i !== null);

        // Add an eventDate.
        $ed = new Event("6", "7", "2011-2-27", "26 Elm St.", "Baton Rouge", "LA", "02722-5511");
        $this->assertTrue(addEvent($ed));

        // Add a street.
        $s = new Event("8", "9", "2012-03-01", "100 Beacon St.", "Boston", "MA", "02134-0211");
        $this->assertTrue(addEvent($s));

        // Add an city.
        $c = new Event("10", "11", "2013-4-28", "28 Belknap St.", "Dover", "NH", "03048-1818");
        $this->assertTrue(addEvent($c));

        // Add an state.
        $st = new Event("12", "13", "2014-5-12", "2 Timberline Dr.", "Little Rock", "AK", "03552-6644");
        $this->assertTrue(addEvent($st));

        // Add an zip.
        $z = new Event("14", "15", "2015-10-15", "88 Jefferson Dr.", "Nashua", "NH", "03063-0308");
        $this->assertTrue(addEvent($z));

        // Try to add a duplicate - should return false.
        $i = new Event("8", "9", "2012-03-01", "100 Beacon St.", "Boston", "MA", "02134-0211");
        $this->assertFalse(addEvent($i));

        //Try to get an event that is not in database.
        $this->assertFalse(getEvent("16"));

        // Get all events for a particular date.
        $ed = getalleventDate("2015-10-15");
        $this->assertTrue(count($ed) == 1);

        // Remove all events
        $this->assertTrue(removeEvent("4"));
        $this->assertTrue(removeEvent("6"));
        $this->assertTrue(removeEvent("8"));
        $this->assertTrue(removeEvent("10"));
        $this->assertTrue(removeEvent("12"));
        $this->assertTrue(removeEvent("14"));

        // Try to remove an event that is not in the database - should not work.
        $this->assertFalse(removeEvent("18"));

        echo("testdbEvent complete");
    }

}
?>



